
package com.mti.monitor.controller;


import com.mti.monitor.bean.model.SysMonitorUser;
import com.mti.monitor.rst.Result;
import com.mti.monitor.service.AuthMonitorService;
import com.mti.monitor.service.SysMonitorUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;


/**
 * 监控平台用户
 */
@Api(value = "monitorUser", description = "monitorUser")
@RestController
@RequestMapping("/user")
@Slf4j
public class MonitorUserController {

    @Autowired
    private SysMonitorUserService sysMonitorUserService;

    @Autowired
    private AuthMonitorService authMonitorService;


    @ApiOperation(value = "用户是否存在", notes = "用户是否存在", httpMethod = "POST")
    @PostMapping(value = "/check")
    public Result<Object> check(HttpServletRequest request, @RequestBody SysMonitorUser user) {
        sysMonitorUserService.userExist(user.getUsername(), user.getPassword());
        request.getSession().setAttribute("user", user.getUsername());
        return Result.ok();
    }


    @ApiOperation(value = "监控服务心跳", notes = "监控服务心跳", httpMethod = "GET")
    @GetMapping(value = "")
    public Result<Object> monitor() {
        return Result.ok();
    }


}
